/* 设置cookie */
// name:键 value:值 days:过期时间，默认是7天
export const setCookie = (name, value, days = 7) => {
  let d = new Date();
  d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * days);
  window.document.cookie =
    name + "=" + value + ";path=/;expires=" + d.toGMTString();
};

/* 获取指定cookie */
export const getCookie = (name) => {
  let v = window.document.cookie.match("(^|;) ?" + name + "=([^;]*)(;|$)");
  return v ? v[2] : null;
};

/* 删除指定cookie */
export const deleteCookie = (name) => {
  setCookie(name, "", -1);
};

/**
 * get请求参数
 * @param params
 */
export const exchangeParams = (params = {}) => {
  return params;
};

/**
 * post请求参数
 * @param data
 * @returns {string}
 */
export const exchangeData = (data = {}) => {
  return JSON.stringify(data);
};
